package com.rq.demo.controller;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.rq.base.util.LOG;
import com.rq.demo.R;

public class LockActivity extends Activity implements View.OnClickListener {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_lock);
        findViewById(R.id.btn_close).setOnClickListener(this);
    }

    @Override
    public void onBackPressed() {

    }

    /*
     *  3.禁止右边回退按键
     * */
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        LOG.e("LockActivity", "57:");
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            Toast.makeText(LockActivity.this, "已屏蔽返回键", Toast.LENGTH_SHORT).show();
            return true;
        }

        if (keyCode == KeyEvent.KEYCODE_HOME) {
            Toast.makeText(LockActivity.this, "不能回到主屏幕", Toast.LENGTH_SHORT).show();
            return true;
        }


         return true;
//        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.btn_close) {
            finish();
        }
    }
}
